package com.guaju.yueshangLife.widget;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.databinding.DataBindingUtil;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;

import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.databinding.EmptyViewBinding;

public class EmptyView extends FrameLayout {
    private LayoutInflater layoutInflater;
    EmptyViewBinding binding;

    public EmptyView(Context context) {
        super(context);
        init();
    }

    public EmptyView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.empty_view);
        boolean goIndex = ta.getBoolean(R.styleable.empty_view_goindex, false);
        String txt = ta.getString(R.styleable.empty_view_txt);
        if (goIndex){
            binding.tvGoIndex.setVisibility(View.GONE);
        }else{
            binding.tvGoIndex.setVisibility(View.VISIBLE);
        }
        if (TextUtils.isEmpty(txt)){
            binding.tvOrderEmpty.setText("暂无数据");
        }else{
            binding.tvOrderEmpty.setText(txt);
        }
    }

    private void init() {
        layoutInflater = LayoutInflater.from(getContext());
        binding = DataBindingUtil.inflate(layoutInflater, R.layout.empty_view, null, false);
        addView(binding.getRoot());
    }
}
